import type { Ref } from "vue";
import type { CascaderTypeListResult } from "@/api/types";
import { ref } from "vue";

interface UseCascaderTypeItemDrawer {
    /** 抽屉状态 */
    drawerVisible: Ref<boolean>;
    /** 当前操作的字典类型 */
    typeRow: Ref<CascaderTypeListResult | null>;
    /** 打开抽屉 */
    openDrawer: (row: CascaderTypeListResult) => void;
}

export function useCascaderTypeItemDrawer(): UseCascaderTypeItemDrawer {
    /** 抽屉状态 */
    const drawerVisible = ref(false);
    /** 当前操作的字典类型 */
    const typeRow = ref<CascaderTypeListResult | null>(null);

    function openDrawer(row: CascaderTypeListResult): void {
        typeRow.value = row;
        drawerVisible.value = true;
    }

    return {
        drawerVisible,
        typeRow,
        openDrawer,
    };
}
